package com.atguigu.staservice.controller;


import com.atguigu.commonutils.R;
import com.atguigu.staservice.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2020-06-24
 */
@RestController
@RequestMapping("/staservice/sta")
//@CrossOrigin
public class StatisticsDailyController {
    @Autowired
    StatisticsDailyService statisticsDailyService;

    /**
     * 统计某一天注册人数
     * @param day
     * @return
     */
    @PostMapping("/countRegister/{day}")
    public R countRegister(@PathVariable("day") String day){
        statisticsDailyService.countRegister(day);
        return R.ok();
    }

    /**
     * 根据日期、类型返回日期Json对象和统计因子数据的Json对象
     * @param type
     * @param begin
     * @param end
     * @return
     */
    @GetMapping("/showData/{type}/{begin}/{end}")
    public R showData(@PathVariable("type") String type,@PathVariable("begin") String begin,
                        @PathVariable("end") String end){
        Map<String,Object> map=statisticsDailyService.showData(type,begin,end);
        return R.ok().data(map);
    }
}

